package co.th.helper.jdbc.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import co.th.helper.jdbc.RowMapper;
import co.th.helper.model.Hospital;

public class HospitalRowMapper extends RowMapper<Hospital>{

	@Override
	public Hospital mapRow(ResultSet resultSet) throws SQLException {
		Hospital hospital = new Hospital();
		if (isThere(resultSet, "hospital_code")){
			hospital.setHospitalCode(resultSet.getBigDecimal("hospital_code"));
		}
		
		if (isThere(resultSet, "hospital_name_th")){
			hospital.setHospitalNameTH(resultSet.getString("hospital_name_th"));
		}
		
		if (isThere(resultSet, "hospital_name_en")){
			hospital.setHospitalNameEN(resultSet.getString("hospital_name_en"));
	    }
		
		if (isThere(resultSet, "hospital_type")){
			hospital.setHospitalType(resultSet.getString("hospital_type"));
		}
		
		if (isThere(resultSet, "address")){
			hospital.setAddress(resultSet.getString("address"));
		}
		
		if (isThere(resultSet, "telephone")){
			hospital.setTelephone(resultSet.getString("telephone"));
		}
		
		if (isThere(resultSet, "email")){
			hospital.setEmail(resultSet.getString("email"));
		}
		
		if (isThere(resultSet, "president_code")){
			hospital.setPresident(resultSet.getBigDecimal("president_code"));
		}
		
		if (isThere(resultSet, "province_id")){
			hospital.setProvince(resultSet.getBigDecimal("province_id"));
		}
		
		if (isThere(resultSet, "region_id")){
			hospital.setRegion(resultSet.getBigDecimal("region_id"));
		}
		
		if (isThere(resultSet, "create_by")){
			hospital.setCreateBy(resultSet.getString("create_by"));
		}
		
		if (isThere(resultSet, "create_date")){
			hospital.setCreateDate(resultSet.getDate("create_date"));
		}
		
		if (isThere(resultSet, "update_by")){
			hospital.setUpdateBy(resultSet.getString("update_by"));
		}
		
		if (isThere(resultSet, "update_date")){
			hospital.setUpdateDate(resultSet.getDate("update_date"));
		}
		
		return hospital;
	}
}
